﻿
@page "/Wms/SaleReturnInWarehouseDetail/Create"
@using nERP.ViewModel.Wms.SaleReturnInWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
  <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit" >
    <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
      <BootstrapInput @bind-Value="@Model.Entity.Seq"/>
      <Select @bind-Value="@Model.Entity.SaleReturnInWarehouseId" Items="AllSaleReturnInWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="gcf954289d7a64116bdb3ba58931cbfaf"/>
      <BootstrapInput @bind-Value="@Model.Entity.SaleReturnInWarehouseDetailCode"/>
      <Select @bind-Value="@Model.Entity.SaleReturnId" Items="AllSaleReturns" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g38fc68714b264100957d4de6937a1565"/>
      <Select @bind-Value="@Model.Entity.SaleReturnDetailId" Items="AllSaleReturnDetails" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g2eb6c03cb8f44fb1ab7f75c0dee52276"/>
      <Select @bind-Value="@Model.Entity.WarehouseId" Items="AllWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g8a27624c21934c19ac8630fc43c3ebe7"/>
      <Select @bind-Value="@Model.Entity.GoodsId" Items="AllGoodss" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g32b6340ad62e49ca98c82401d4048d49"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsName"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsSpec"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsUnit"/>
      <BootstrapInput @bind-Value="@Model.Entity.ReturnNumber"/>
      <BootstrapInput @bind-Value="@Model.Entity.Remark"/>
    </Row>

    <div class="modal-footer table-modal-footer">
      <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
      <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
    </div>

  </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SaleReturnInWarehouseDetailVM Model = new SaleReturnInWarehouseDetailVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {
                        
        
        await PostsForm(vform, "/api/Wms/SaleReturnInWarehouseDetail/Create", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllSaleReturnInWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllSaleReturns = new List<SelectedItem>();
    private List<SelectedItem> AllSaleReturnDetails = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllSaleReturnInWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturnInWarehouses");
        AllSaleReturnInWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSaleReturns = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturns");
        AllSaleReturns.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSaleReturnDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturnDetails");
        AllSaleReturnDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
